package com.itheima.test1;

import java.util.ArrayList;

public class Test1 {
    public static void main(String[] args) {
        HaSiQi haSiQi = new HaSiQi();
        haSiQi.setName("hasiqi");
        haSiQi.setAge(20);

        //创建集合，用于存储动物对象
        ArrayList<BoSi> list1=new ArrayList<>();
        ArrayList<LiHua> list2=new ArrayList<>();
        ArrayList<TaiDi> list3=new ArrayList<>();
        ArrayList<HaSiQi> list4=new ArrayList<>();

        list1.add(new BoSi("bosi",1));
        list2.add(new LiHua("LiHua",1));
        list3.add(new TaiDi("TaiDi",1));
        list4.add(haSiQi);



        //饲养
        keepPet(list1);
        keepPet(list2);
        keepPet(list3);
        keepPet(list4);
    }

    //饲养
    public static void keepPet(ArrayList<? extends Animal> list) {
        list.get(0).eat();
        list.get(3).eat();
        list.get(1).eat();
        list.get(2).eat();

    }
}
